Skip to content

Optimize post-if stack reuse and refresh exact script tests#83

Open
someone235 wants to merge 5 commits intokaspanet:masterfrom
someone235:reassign-opt
Open

Optimize post-if stack reuse and refresh exact script tests#83
someone235 wants to merge 5 commits intokaspanet:masterfrom
someone235:reassign-opt

Conversation

@someone235
Copy link
Copy Markdown
Contributor

Summary

This PR improves how the compiler handles reassigned locals, especially across if branches, and reduces redundant stack work when a reassigned value is consumed for the last time.

What changed

  • Fixed stack-local reassignment cleanup so the compiler removes the correct stack slot instead of assuming the old value is always on top.
  • Kept overwritten stack slots tracked as hidden shadow bindings until cleanup, so later stack-depth calculations stay correct after reassignment.
  • Used OpRoll instead of OpPick in the targeted reassignment cases where a stack value is being consumed for the last time, which avoids extra cleanup.
  • Made if normalization more reliable when outer variables are reassigned in only one branch.
  • Ensured synthetic __if_* values are materialized consistently across branches so merged stack and type state stay correct.
  • Cleaned up branch-local hidden shadow bindings so they do not leak into later control flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant